package com.huaxia.util;



import com.huaxia.service.A_updateFHS.QuarterFHSService;

import com.huaxia.service.update.UpdateYxAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Calendar;


/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/04/22 10:29
 */
//定时从数据库中获取数据存入ServletContext中
@Component
public class CronTask {

    @Autowired
    private CommonMethods commonMethods;

    @Autowired
    private QuarterFHSService quarterFHSService;

    @Autowired
    private UpdateYxAgentService updateYxAgentService;




    @Scheduled(cron = "0 0,30 1-23 * * ?")
    public void updateData(){
        commonMethods.commonMethodsYxOne();
    }

    @Scheduled(cron = "0 40 1-23 * * ?")
    public void updateData2(){
        commonMethods.commonMethodsYxTwo();
    }

    @Scheduled(cron = "0 20 8,15 * * ?")
    public void updateData3(){
        commonMethods.commonMethodsYxThree();
    }

    //每个季度最后一天  更新四星业务员
    @Scheduled(cron ="0 50 22 * 3-12/3 ?")
    public void updateFHS(){
        final Calendar c = Calendar.getInstance();
        if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {
            quarterFHSService.updateFHS();
        }
    }

    @Scheduled(cron = "0 10 2 * * ?")
    public void updateAllYxAgent(){
        updateYxAgentService.updateAllYxAgent();
    }

}
